package cn.iocoder.yudao.module.im.dal.mapper;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.im.dal.dataobject.ImGroupAnnouncementDO;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

/**
 * 群公告表 Mapper
 */
@Mapper
public interface ImGroupAnnouncementMapper extends BaseMapperX<ImGroupAnnouncementDO> {

    /**
     * 查询指定群组的公告列表
     */
    default List<ImGroupAnnouncementDO> selectListByGroupId(Long groupId) {
        // 使用QueryWrapper替代方法引用
        QueryWrapper<ImGroupAnnouncementDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("group_id", groupId);
        return selectList(queryWrapper);
    }

    /**
     * 查询指定群组的最新公告
     */
    default ImGroupAnnouncementDO selectLatestByGroupId(Long groupId) {
        // 使用QueryWrapper替代方法引用
        QueryWrapper<ImGroupAnnouncementDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("group_id", groupId);
        return selectOne(queryWrapper);
    }

}